package 数组练习题;

import java.util.Arrays;

public class Demo13 {
    public static void main(String[] args) {
        double[] arr=new double[10];
        for (int i = 0; i < arr.length-1; i++){
            arr[i]=Math.random()*100;
        }
        arr[arr.length-1]=0;
        System.out.println("直线上每一个点距离下一个点的距离:"+ Arrays.toString(arr));
        double length=150.05;
        int count=0;
        double sum=0;
        for (int i = 0; i < arr.length; i++){
            sum+=arr[i];
            if(sum<=length){
                count++;
            }else {
                break;
            }
        }
        System.out.println("长度为:"+length+"的绳子最多能覆盖"+count+"个点");
    }
}
